package com.efounder.frame.title;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.LinearLayout;


import com.efounder.mobilemanager.R;
import com.efounder.frame.widget.EFSlidingTabStrip;

/**
 * Created by XinQing on 2016/8/16.
 */

public class EFSlidingTabStripTitleView extends EFSimpleTitleView {

    private EFSlidingTabStrip slidingTabStrip;

    public EFSlidingTabStripTitleView(Context context) {
        super(context);
    }

    @Override
    public void initCenterLayout(LinearLayout centerLayout) {
        slidingTabStrip = new EFSlidingTabStrip(centerLayout.getContext());
        //这样设置，单个item会居中显示
        slidingTabStrip.setShouldExpand(true);
        //设置下划线颜色:透明
        slidingTabStrip.setUnderlineColor(0x00000000);
        //设置滑动条指示器高度
        slidingTabStrip.setIndicatorHeight((int) getResources().getDimension(R.dimen.ef_title_sliding_tab_view_indicator_height));
        //设置滑动条指示器颜色
        slidingTabStrip.setIndicatorColorResource(R.color.ef_white);
        //设置字体颜色
        slidingTabStrip.setTextColorResource(R.color.ef_white);
        //设置字体大小
        slidingTabStrip.setTextSize((int) getResources().getDimension(R.dimen.ef_title_sliding_tab_view_text_size));
        //设置缩放字体大小
        slidingTabStrip.setTabScaleTextSize((int) getResources().getDimension(R.dimen.ef_title_sliding_tab_view_scale_text_size));
        //设置只有一个Tab项时，不显示indicator
        slidingTabStrip.setShowIndicatorWhenOneTab(false);
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        LinearLayout.LayoutParams efPagerSlidingTabStripParams = new LinearLayout.LayoutParams(width,height);
        efPagerSlidingTabStripParams.leftMargin = (int) getResources().getDimension(R.dimen.ef_title_sliding_tab_view_margin_horizontal);
        efPagerSlidingTabStripParams.rightMargin = (int) getResources().getDimension(R.dimen.ef_title_sliding_tab_view_margin_horizontal);
        slidingTabStrip.setLayoutParams(efPagerSlidingTabStripParams);
        centerLayout.addView(slidingTabStrip);
    }

    public EFSlidingTabStrip getEfPagerSlidingTabStrip() {
        return slidingTabStrip;
    }

}
